package com.lyl.lawyer.exception;

import com.cn.lyl.lawyer.util.CommonResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class ExceptionController {

    @ExceptionHandler(Exception.class)
//	@ResponseBody
//	@ResponseStatus(code= HttpStatus.INTERNAL_SERVER_ERROR)
    public CommonResult<Object> runtimeExceptionResolve(Exception exception) {
		/*
		 * 指定返回值的编码和内容类型，
		 并通过response的PrintWriter对象将自定义的返回值返回给调用方。
		 */
        exception.printStackTrace();
        return CommonResult.failed(exception.getMessage());
    }
}